package cn.demoncat.util.exception;

import cn.demoncat.util.lang.entity.Result;

/**
 * 参数异常
 * 
 * 场景：开发者未按规定校验和传递参数 
 * 使用：程序中参数不合法时直接抛出异常，由统一异常处理器拦截，传递到程序的请求端在开发时处理
 *
 * @author 延晓磊
 *
 * @since 2017年3月26日
 */
public class ParamRuntimeException extends WarnRuntimeException {

	/**
	 * 常用异常：参数为空
	 */
	public static final ParamRuntimeException NULL = new ParamRuntimeException(Result.ERROR_PARAM_NULL.getMsg());
	
	/**
	 * 常用异常：参数不符合规范
	 */
	public static final ParamRuntimeException ILLEGAL = new ParamRuntimeException(Result.ERROR_PARAM_ILLEGAL.getMsg());
	
	/**
	 * 常用异常：参数错误，不是要求的参数，不符合规范
	 */
	public static final ParamRuntimeException ERROR = new ParamRuntimeException(Result.ERROR_PARAM_ERROR.getMsg());

	/**
	 * 数据为空：根据参数查询的数据为空
	 */
	public static final ParamRuntimeException DATA_NULL = new ParamRuntimeException(Result.ERROR_DATA_NULL.getMsg());

	/**
	 * 断言
	 *
	 * @param isError
	 * @param msg
	 */
	public static void asserts(boolean isError, String msg){
		if (isError) {
			throw new ParamRuntimeException(msg);
		}
	}

	public ParamRuntimeException() {
		super();
	}

	public ParamRuntimeException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
		super(message, cause, enableSuppression, writableStackTrace);
	}

	public ParamRuntimeException(String message, Throwable cause) {
		super(message, cause);
	}

	public ParamRuntimeException(String message) {
		super(message);
	}

	public ParamRuntimeException(Throwable cause) {
		super(cause);
	}

	public ParamRuntimeException(String message, String code, Throwable cause) {
		super(message, code, cause);
	}

	public ParamRuntimeException(String message, String code) {
		super(message, code);
	}
}
